<template>
  <!-- 卡片视图 -->
  <el-card>
    <el-table
      style="width: 100%"
      :data="rightList"
      stripe
      border>
      <el-table-column label="#" type="index"></el-table-column>
      <el-table-column label="权限名称" prop="authName"></el-table-column>
      <el-table-column label="路径" prop="path"></el-table-column>
      <el-table-column label="权限层级" prop="level">
        <template v-slot="scope">
          <el-tag v-if="scope.row.level === '0'">一级</el-tag>
          <el-tag type="success" v-if="scope.row.level === '1'">二级</el-tag>
          <el-tag type="warning" v-if="scope.row.level === '2'">三级</el-tag>
        </template>
      </el-table-column>
    </el-table>
  </el-card>
</template>

<script>
export default {
  data () {
    return {
      // 参数类型
      type: 'list',
      // 权限列表
      rightList: []
    }
  },
  methods: {
    async getRightsList () {
      const { data, meta } = (await this.$http.get('rights/' + this.type)).data
      if (meta.status !== 200) return this.$message.error(meta.msg)
      this.rightList = data
    }
  },
  mounted () {
    this.getRightsList()
  }
}
</script>

<style lang="less" scoped>
.el-card.is-always-shadow {
  box-shadow: 0 1px 1px rgba(0, 0, 0, .15);
}
</style>
